//
//  BaseNavViewController.m
//  ZhuKuang
//
//  Created by jayce on 17/7/14.
//  Copyright © 2017年 jjkj. All rights reserved.
//

#import "BaseNavViewController.h"
#import "SetPwdViewController.h"
#import "YHTimeViewController.h"

@interface BaseNavViewController ()

@end

@implementation BaseNavViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self setUpNavigationBar];
    [self createDateSelected];
}

//时间选择
- (void)createDateSelected{
    
    UIButton *dateBtn = [[UIButton alloc]init];
    [dateBtn setTitle:[CommClass getTodayDateStr] forState:UIControlStateNormal];
    dateBtn.bounds = CGRectMake(0, 0, 100, 64);
    [dateBtn addTarget:self action:@selector(DateSelectedButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.titleView = dateBtn;
}

- (void)DateSelectedButtonClick:(UIButton *)sender{
    
}
//设置状态栏颜色
-(UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
//设置导航栏
- (void)setUpNavigationBar {
    
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#1395CE"];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationController.navigationBar.opaque = NO;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:[self leftButtonItem]];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:[self rightButtonItem]];
}

#pragma mark - leftButtonItem
- (UIView *)leftButtonItem {
    
    UIButton *left = [UIButton buttonWithType:UIButtonTypeCustom];
    left.frame = CGRectMake(0, 0, 30, 30);
    [left setBackgroundImage:[UIImage imageNamed:@"set"] forState:UIControlStateNormal];
    [left addTarget:self action:@selector(p_leftButtonItemAction) forControlEvents:UIControlEventTouchUpInside];
    return left;
}

#pragma mark - rightButtonItem
- (UIView *)rightButtonItem {
    
    UIButton *right = [UIButton buttonWithType:UIButtonTypeCustom];
    right.frame = CGRectMake(0, 0, 30, 30);
    [right setBackgroundImage:[UIImage imageNamed:@"clock"] forState:UIControlStateNormal];
    [right addTarget:self action:@selector(p_rightButtonItemAction) forControlEvents:UIControlEventTouchUpInside];
    return right;
}
#pragma mark - leftButtonItemAction
- (void)p_leftButtonItemAction {
    
    SetPwdViewController *set = [[SetPwdViewController alloc]initWithNibName:@"SetPwdViewController" bundle:nil];
    [self.navigationController pushViewController:set animated:YES];
}
#pragma mark - rightButtonItemAction
- (void)p_rightButtonItemAction {
    
    YHTimeViewController *time = [[YHTimeViewController alloc]initWithNibName:@"YHTimeViewController" bundle:nil];
    [self.navigationController pushViewController:time animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
